//
//  DGGNetworkHelper.h
//  DGGNetworkingSDK
//
//  Created by Dwt on 2019/12/25.
//

#ifndef weakify
#if DEBUG
#if __has_feature(objc_arc)
#define weakify(object) autoreleasepool{} __weak __typeof__(object) weak##_##object = object;
#else
#define weakify(object) autoreleasepool{} __block __typeof__(object) block##_##object = object;
#endif
#else
#if __has_feature(objc_arc)
#define weakify(object) try{} @finally{} {} __weak __typeof__(object) weak##_##object = object;
#else
#define weakify(object) try{} @finally{} {} __block __typeof__(object) block##_##object = object;
#endif
#endif
#endif

#ifndef strongify
#if DEBUG
#if __has_feature(objc_arc)
#define strongify(object) autoreleasepool{} __typeof__(object) object = weak##_##object;
#else
#define strongify(object) autoreleasepool{} __typeof__(object) object = block##_##object;
#endif
#else
#if __has_feature(objc_arc)
#define strongify(object) try{} @finally{} __typeof__(object) object = weak##_##object;
#else
#define strongify(object) try{} @finally{} __typeof__(object) object = block##_##object;
#endif
#endif
#endif

#ifndef __OPTIMIZE__

#define NSLog(...) NSLog(__VA_ARGS__)

#else

#define NSLog(...){}

#endif


#import <Foundation/Foundation.h>

typedef NS_ENUM(NSUInteger, DGGNetworkErrorMsgType) {
    DGGNetworkErrorMsgTimeout = 0,   //网络超时
    DGGNetworkErrorMsgCancel,        //取消
    DGGNetworkErrorMsgFailed,        //失败
};

NS_ASSUME_NONNULL_BEGIN

@interface DGGNetworkHelper : NSObject

/// 单例
+ (instancetype)shareInstance;

/// (必需)定义消息提示的key，默认是@"message"，由开发者统一失败提示，本基础框架不接入UI相关
@property (nonatomic, copy) NSString *messageKey;

/// 网络是否连接
- (BOOL)isNetworkAvailable;

- (NSDictionary *)error:(DGGNetworkErrorMsgType)msgType;

@end

NS_ASSUME_NONNULL_END
